package com.test14_枚举;

/**
 * 枚举应用案例
 */
public class YootkDemo_04 {

    public static void main(String[] args) {
        Book book = new Book("Java从入门到项目实战", "小李老师", 99.8, BookType.PROGRAM);
        System.out.println(book);
    }
}

enum BookType {     // 图书类型
    MATH("数学"), PROGRAM("软件编程"), GAME("游戏");

    private String content;

    BookType(String content) {
        this.content = content;
    }

    @Override
    public String toString() {
        return this.content;
    }
}

class Book {    // 图书类
    private String title;
    private String author;
    private double price;
    private BookType type;  // 图书类型

    public Book(String title, String author, double price, BookType type) {
        this.title = title;
        this.author = author;
        this.price = price;
        this.type = type;
    }

    @Override
    public String toString() {
        return "【图书】名称：" + this.title + "、作者：" + this.author + "、价格：" + this.price + "、类型：" + this.type;
    }
}
